<template>
  <div class="layout">
    <Layout
      style="position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px"
    >
      <Header>
        <h1 class="layout-head">在线工具集</h1>
      </Header>
      <Layout>
        <Sider
          hide-trigger
          :style="{ background: '#fff', height: 'calc(100% - 48px)' }"
        >
          <Menu
            :active-name="activeName"
            theme="light"
            width="auto"
            :open-names="['my-tool']"
            accordion
          >
            <Submenu name="my-tool">
              <template slot="title">
                <Icon type="md-construct" />
                <span class="layout-first-title">自研工具</span>
              </template>
              <MenuItem name="sql2proto" to="/home/sql2proto"
                >SQL转Proto</MenuItem
              >
              <!-- <MenuItem name="dec" to="/home/dec">Cj-解密</MenuItem> -->
              <!-- <MenuItem name="enc" to="/home/enc">Cj-加密</MenuItem> -->
              <MenuItem name="formatjson" to="/home/formatjson"
                >格式化Json</MenuItem
              >
              <MenuItem name="json2struct" to="/home/json2struct"
                >Json转Struct</MenuItem
              >
              <MenuItem name="md5" to="/home/md5">在线 Md5</MenuItem>
            </Submenu>
            <Submenu name="ta-tool">
              <template slot="title">
                <Icon type="ios-link" />
                <span class="layout-first-title">他人工具</span>
              </template>
              <MenuItem
                name="resize-img"
                to="https://www.gaitubao.com/"
                target="_blank"
                >图片裁剪</MenuItem
              >
              <MenuItem
                name="regular"
                to="https://c.runoob.com/front-end/854/"
                target="_blank"
                >在线正则表达式</MenuItem
              >
            </Submenu>
          </Menu>
        </Sider>
        <Layout :style="{ padding: '0 24px 24px' }">
          <Content
            :style="{
              margin: '24px 0',
              padding: '24px',
              minHeight: '280px',
              background: '#fff',
            }"
          >
            <router-view />
          </Content>
        </Layout>
      </Layout>
    </Layout>
  </div>
</template>
<script>
export default {
  data() {
    return {
      activeName: "sql2proto",
    };
  },
  methods: {
    initActive() {
      let curUrl = this.$route.path;
      let lastUrlSplitIndex = curUrl.lastIndexOf("/");
      this.activeName = curUrl.substr(lastUrlSplitIndex + 1);
    },
  },
  created() {
    this.initActive();
  },
};
</script>

<style scoped>
.layout {
  border: 1px solid #d7dde4;
  background: #f5f7f9;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  height: 100%;
  width: 100%;
  overflow: scroll;
}
.layout-logo {
  width: 100px;
  height: 30px;
  background: #5b6270;
  border-radius: 3px;
  float: left;
  position: relative;
  top: 15px;
  left: 20px;
}
.layout-nav {
  width: 420px;
  margin: 0 auto;
  margin-right: 20px;
}
.layout-first-title {
  font-weight: bold;
}
.layout-head {
  color: white;
}
</style>
